<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('sup_form')" />
</head>
<body class="white-bg">
	<div class="main-content">
		<form class="form-horizontal" id="form">
			<input id="pageFlag" name="pageFlag" type="hidden" th:value="${sup.pageFlag}" />
			<input id="id" name="id" type="hidden" th:value="${sup.id}" />
			<input id="type" name="type" type="hidden" th:value="${sup.type}" />
			<div class="form-group">
				<label class="col-sm-3 control-label is-required">考核月份<br/>(不支持修改)</label>
				<div class="col-sm-8">
					<input name="monthId" id="monthId" th:value="${sup.monthId}" class="form-control" type="text" required />
				</div>
			</div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">填报类型</label>
                <div class="col-sm-8">
                    <select class="form-control m-b" required
                        th:with="dicts=${@dict.getType('rate_sup_type')}" disabled="disabled">
                        <option value="">请选择</option>
                        <option th:each="dict : ${dicts}" th:selected="${sup.type == dict.dictValue}"
                            th:text="${dict.dictLabel}" th:value="${dict.dictValue}" />
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">被考核部门<br/>(不支持修改)</label>
                <div class="col-sm-8">
                    <select id="dept.deptId" name="dept.deptId" class="form-control m-b" required>
                        <option value="">请选择</option>
                        <option th:each="dept : ${deptList}" th:text="${dept.deptName}" th:value="${dept.deptId}"
                            th:selected="${sup.dept.deptId == dept.deptId}" />
                    </select>
                </div>
            </div>
            <div class="form-group" th:if="${'JF' == sup.type || 'KF' == sup.type || 'SZPY' == sup.type || 'KHB' == sup.type}">
                <label class="col-sm-3 control-label is-required" th:if="${'JF' == sup.type}">加分<br/>(请填写大于0的数字)</label>
                <label class="col-sm-3 control-label is-required" th:if="${'KF' == sup.type}">扣分<br/>(请填写小于0的数字)</label>
                <label class="col-sm-3 control-label is-required" th:if="${'SZPY' == sup.type}">得分<br/>(请填写非0的数字)</label>
                <label class="col-sm-3 control-label is-required" th:if="${'KHB' == sup.type}">得分<br/>(请填写非0的数字)</label>
                <div class="col-sm-8">
                    <input name="score" id="score" th:value="${sup.score}" class="form-control" type="text" required />
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">详情</label>
                <div class="col-sm-8">
                    <textarea class="form-control" name="content1" id="content1"
                        th:text="${sup.content1}" rows="3" maxlength="512" required></textarea>
                </div>
            </div>
		</form>
	</div>
	<th:block th:include="include :: footer" />
	<th:block th:include="include :: datetimepicker-css" />
	<th:block th:include="include :: datetimepicker-js" />
	<script>
		var prefix = ctx + "rate/sup";
		var pageFlag = '[[${sup.pageFlag}]]';
		
		$(function() {
			$("#monthId").datetimepicker({
				format: 'yyyy-mm',
				weekStart: 1,
				autoclose: true,
				startView: 3,
				minView: 3
			});
			
			if ("ADD" == pageFlag || "EDIT" == pageFlag) {
			} else if ("VIEW" == pageFlag) {
				$("#form input[type='text']").prop("disabled", true);
				$("#form textarea").prop("disabled", true);
				$("#form select").prop("disabled", true);
			}
		});
		
		function submitHandler() {
			if (pageFlag == "ADD" || pageFlag == "EDIT") {
				if ($.validate.form()) {
					$.modal.confirm("确定保存数据？", function() {
						$.operate.save(prefix + "/save", $('#form').serialize());
					});
				}
			}
			/**else if (pageFlag == "KHZ" || pageFlag == "FGLD" || pageFlag == "HZ") {
				if ($("input[name='checkResult']:checked").val() == null) {
					$.modal.alertWarning("请选择审批结果！");
					return false;
				}
				if ($("input[name='checkDesc']").val() == "") {
					$.modal.alertWarning("请填写审批意见！");
					return false;
				}
				
				if (pageFlag == "KHZ") {
					if (!$("#fgldChecker\\.userId").val()) {
						$.modal.alertWarning("请选择分管领导！");
						return false;
					}
				}
				
				if ($.validate.form()) {
					$.operate.save(prefix + "/submitCheck", $('#form').serialize());
				}
			}
			**/
			else {
				var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
				parent.layer.close(index); //再执行关闭
				return true;
			}
		}
	</script>
</body>
</html>
